﻿#region usings
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Navigation;
using InsuranceAdjuster.Models;
using InsuranceAdjuster.Views;
using InsuranceAdjuster.Web.Models;
#endregion
namespace InsuranceAdjuster {

    public partial class Home : Page {
        private ViewModels.AdjusterDashboardViewModel _viewModel;
        #region Initializaers
        public Home() {
            _viewModel = ((ViewModels.ViewModelLocator)(App.Current.Resources["Locator"])).Appointments;
            InitializeComponent();
        }

        #endregion

        private void OnAppointmentsListboxSelectionChanged(object sender, SelectionChangedEventArgs e) {
            if (null != ((ListBox)(sender)).SelectedItem) {
                // TODO: Convert to a Custom Markup Extension
                _viewModel.OnAppointmentChanged();
            }
        }
        #region Multiple Windows
        private void OnOpenClaim(object sender, RoutedEventArgs e) {
            if (Application.Current.IsRunningOutOfBrowser) {
                Window w = new Window();
                FrameworkElement content = new IncidentViewWithBackground();
                w.Content = content;
                w.Height = content.Height;
                w.Width = content.Width;
                w.Title = "Incident";
                w.Visibility = Visibility.Visible;
            } else {
                (sender as HyperlinkButton).NavigateUri = new System.Uri("/IncidentView", System.UriKind.Relative);
            }
        }
        #endregion

        #region ColumnChooser
        private void columnChooserToggle(object sender, MouseButtonEventArgs e) {
            if (columnChooser.Visibility != Visibility.Collapsed) {
                this.RotateDetailsBack.Begin();
                _viewModel.FillClaimDetails();
            } else {
                this.RotateDetails.Begin();
            }
        }
        #endregion

    }
}